import times

type
  Suffix* = enum
    First = 1, Last = 2, Second = 8, Teenth = 13, Third = 15, Fourth = 22, Fifth = 29 

proc meetup*(year, month: int; start: Suffix, day: WeekDay): string = 
  var date = initDateTime(int(start), Month(month), year, 0, 0, 0, 0)
  
  if start == Last: 
    date += 1.months - 8.days

  # next weekday
  if start.weekday <= day:
    date += (day.ord - start.weekday.ord).days
  else:
    date += (7 - start.weekday.ord + day.ord).days

  date.format("YYYY-MM-dd")
